﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GIS地图坐标转换_坐标转换对比 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }




    protected void Button1_Click(object sender, EventArgs e)
    {

        double wgslon = double.Parse(lonwgs.Text);
        double wgslat = double.Parse(latwgs.Text);

        //转换为google坐标
        double[] googleCoords = new double[2];
        //gps坐标转换
        Skybot.CoordConverts.GpsCoodCorrect.transform(wgslat, wgslon, googleCoords);
        latgoogle.Text = googleCoords[0].ToString();
        longoogle.Text = googleCoords[1].ToString();

        double baiduLon, baiduLat;
        //百度坐标转换
        Skybot.CoordConverts.BaiduCoordConveter.BdEncrypt(googleCoords[0], googleCoords[1], out baiduLat, out baiduLon);
        latbaidu.Text = baiduLat.ToString();
        lonbaidu.Text = baiduLon.ToString();

        #region 综合转换类转换
        double[] gjc = MapGisCoodConverter.gcj_encrypt(wgslat, wgslon);
        Response.Write(string.Format("火星坐标 Lat:{0};Lon:{1}<br/>", gjc[0], gjc[1]));
        double[] baidu = MapGisCoodConverter.bd_encrypt(gjc[0], gjc[1]);
        Response.Write(string.Format("百度坐标 Lat:{0};Lon:{1}<br/>", baidu[0], baidu[1]));
        double[] mercator = MapGisCoodConverter.mercator_encrypt(wgslat, wgslon);
        Response.Write(string.Format("Web 坐标 Lat:{0};Lon:{1}<br/>", mercator[0], mercator[1]));
        //计算距离
        Response.Write(string.Format("官方 baiLat:{0},baiLon:{1};<br/>本地 baiLat:{2},baiLon:{3}<br/>距离 官方:{4}米,本地:{5}",
           39.916979519873, 116.41004950566,
           39.9169728560751, 116.410044101705,
           0.99,
           MapGisCoodConverter.distance(baidu[0],baidu[1], 39.916979519873,  116.41004950566 )
            ));
        #endregion
    }
}